package io.adrainty.algorithm.leetcode.lcr;

/**
 * <p>LCR018. 验证回文串</p>
 * <a href="https://leetcode.cn/problems/XltzEq/description/">...</a>
 * @author AdRainty
 * @version V1.0.0
 * @description LCR018
 * @since 2025/7/28 14:31:57
 */
public class LCR018 {

    public boolean isPalindrome(String s) {
        int l = 0, r = s.length() - 1;
        while (l < r) {
            while (l < r && !Character.isLetterOrDigit(s.charAt(l))) l++;
            while (l < r && !Character.isLetterOrDigit(s.charAt(r))) r--;
            if (Character.toLowerCase(s.charAt(l)) != Character.toLowerCase(s.charAt(r))) return false;
            l++; r--;
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new LCR018().isPalindrome("A man, a plan, a canal: Panama"));
    }

}
